package Aaaaaa;

import java.util.Scanner;

public class Main3 {
    public static int count;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str1=sc.nextLine();
        String str2=sc.nextLine();
        count=0;
        StringBuilder strB1=new StringBuilder(str1);
        while(!isContains(strB1,str2)){
            strB1.append(str1);
        }
        int n=str2.length();
        for(int i=0;i<n;i++){
            strB1.append(str1);
        }
        System.out.println(strB1);
        System.out.println(count);
    }
    private static boolean isContains(StringBuilder strB1, String str2) {
        int index1=0;
        int index2=0;
        String str1=strB1.toString();
        boolean[] b=new boolean[str2.length()+1];
        b[0]=true;
        while(index1<str1.length()&&index2<str2.length()){
            if(str1.charAt(index1)==str2.charAt(index2)){
                b[index2+1]=b[index2];
                index1++;
                index2++;
            }else{
                index1++;
            }
        }
        count=index1-str2.length();
        return b[b.length-1];
    }
}
